{% extends 'base.html' %}

{% block title %}我的需求 - 校园技能交换平台{% endblock %}

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
    <h2>我的需求</h2>
    <a href="{% url 'listings:need_create' %}" class="btn btn-primary">
        <i class="bi bi-plus-lg"></i> 发布新需求
    </a>
</div>

<div class="row row-cols-1 row-cols-md-2 g-4">
    {% for need in needs %}
    <div class="col">
        <div class="card h-100">
            <div class="card-body">
                <h5 class="card-title">
                    <a href="{% url 'listings:need_detail' need.pk %}" class="text-decoration-none">{{ need.title }}</a>
                </h5>
                <p class="card-text text-truncate">{{ need.description }}</p>
                <div class="d-flex justify-content-between align-items-center">
                    <small class="text-muted">{{ need.get_category_display }}</small>
                    <small class="text-muted">{{ need.get_preferred_solution_display }}</small>
                </div>
            </div>
            <div class="card-footer d-flex justify-content-between align-items-center">
                <small class="text-muted">
                    发布时间: {{ need.created_at|date:"Y-m-d" }} | 
                    状态: {% if need.is_resolved %}已解决{% else %}待解决{% endif %}
                </small>
                <div>
                    <a href="{% url 'listings:need_edit' need.pk %}" class="btn btn-sm btn-outline-primary">编辑</a>
                </div>
            </div>
        </div>
    </div>
    {% empty %}
    <div class="col-12">
        <div class="alert alert-info" role="alert">
            您还没有发布任何需求。<a href="{% url 'listings:need_create' %}" class="alert-link">立即发布</a>
        </div>
    </div>
    {% endfor %}
</div>
{% endblock %} 